//
//  FirstGViewController.m
//  DaJiHui
//
//  Created by Hao on 2017/6/26.
//  Copyright © 2017年 Hao. All rights reserved.
//
#import "FirstTwoViewController.h"
#import "NSArray+CZSafeAccess.h"
#import "FirstModel.h"
#import "AFNetworking.h"
#import "JiFenViewController.h"
#import "YeShiViewController.h"
#import "DingZuoViewController.h"
#import "ShangPinViewController.h"
#import "ChengXinViewController.h"
#import "ZhiGongJiHuiViewController.h"
#import "ShangCangViewController.h"
#import "SecondGViewController.h"
#import "FirstOTableViewCell.h"
#import "SMS_Scroll_ImageView.h"
#import "FirstGViewController.h"
#import "DaJiHui-Swift.h"
#import "SecondGViewController.h"
#import "WebViewController.h"

@interface FirstGViewController ()<UITableViewDelegate, UITableViewDataSource,FSPagerViewDataSource,FSPagerViewDelegate>
@property(nonatomic, strong)UITableView *myTableView;
@property(nonatomic, strong)UIButton *btn1;
@property(nonatomic, strong)UIButton *btn2;
@property(nonatomic, strong)UIButton *btn3;
@property(nonatomic, strong)UIButton *btn4;
@property(nonatomic, strong)UIButton *btn5;
@property(nonatomic, strong)UIButton *btn6;
@property(nonatomic, strong)UIButton *btn7;
@property(nonatomic, strong)UIButton *btn8;
@property(nonatomic, strong)UIButton *btn9;
@property(nonatomic, strong)UIButton *btn10;
@property(nonatomic, strong)UIButton *btn11;
@property(nonatomic,strong)UILabel *lab1;
@property(nonatomic,strong)UILabel *lab2;
@property(nonatomic,strong)UILabel *lab3;
@property(nonatomic,strong)UILabel *lab4;
@property(nonatomic,strong)UILabel *lab5;
@property(nonatomic,strong)UILabel *lab6;
@property(nonatomic,strong)UILabel *lab7;
@property(nonatomic,strong)UILabel *lab8;
@property(nonatomic,strong)UILabel *weatherLab;
@property (weak  , nonatomic) IBOutlet FSPageControl *pageControl;
@property (strong, nonatomic) NSArray<NSString *> *imageNames;
@property (weak  , nonatomic) IBOutlet UITableView *tableView;
@property (strong  , nonatomic) FSPagerView *pagerView;
@property (nonatomic ,strong) NSMutableDictionary *firstData;
@property (nonatomic ,strong) NSMutableArray * dataArray;
@property(nonatomic, strong)NSMutableArray *bannerArr;
@property(nonatomic, strong)NSMutableArray *gongSiArr;
@property(nonatomic, strong)NSDictionary *dataDic;
@property(nonatomic, strong)NSMutableArray *gearrSiArr;
@property(nonatomic, strong)NSMutableArray *gtarrSiArr;
@property(nonatomic, strong)NSMutableArray *ptarrSiArr;
@property(nonatomic, strong)NSMutableArray *poarrSiArr;
@property(nonatomic, strong)NSMutableArray *toarrSiArr;

@end

@implementation FirstGViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self gada];
    [self makeBaseUI];
    [self horseLight];
    [self.tableView reloadData];
    self.view.backgroundColor= [UIColor whiteColor];

    // Do any additional setup after loading the view.
}
-(void)gada{
    // 数据请求
    _toarrSiArr = [[NSMutableArray alloc]init];
    _ptarrSiArr = [[NSMutableArray alloc]init];
    _poarrSiArr = [[NSMutableArray alloc]init];
    _dataArray = [[NSMutableArray alloc]init];
    _gtarrSiArr =[[NSMutableArray alloc]init];
    _gearrSiArr = [[NSMutableArray alloc]init];
    _gongSiArr = [[NSMutableArray alloc]init];
    _bannerArr = [[NSMutableArray alloc]init];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer.timeoutInterval = 10.f;
    manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingMutableContainers];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.requestSerializer.HTTPMethodsEncodingParametersInURI = [NSSet setWithArray:@[@"POST", @"GET", @"HEAD"]];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"application/json",@"text/javascript",nil];
    NSURL *url = [NSURL URLWithString:@"http://www.chaojihui123.com/phonedata.php?s=/Index/index"];
    [manager POST:url.absoluteString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"成功%@",responseObject);
        if (responseObject) {
            _ptarrSiArr = responseObject[@"brows"];
            _gearrSiArr = responseObject[@"orow"];
            _dataArray = responseObject[@"lunbo"];
            _gongSiArr = [FirstModel transformWithArry:responseObject[@"rest"]];
            
            
            for (NSMutableDictionary *dic in _dataArray)
            {
                NSLog(@"%@", dic);
                NSMutableString *str= [[NSMutableString alloc]initWithString:[NSString stringWithFormat:@"%@",dic[@"pic"]]];
                [str deleteCharactersInRange:NSMakeRange(0, 8)];
                NSLog(@"%@",str);
                [_bannerArr addObject:[NSString stringWithFormat:@"http://www.chaojihui123.com%@",str]];
                NSLog(@"%@",self.bannerArr);
                
            }
            for (NSMutableDictionary *dic in _gearrSiArr)
            {
                NSMutableString *str= [[NSMutableString alloc]initWithString:[NSString stringWithFormat:@"%@刚刚购买了%@,共获得了%@积分",dic[@"memmobile"],dic[@"waretitle"],dic[@"getintegral"]]];
                [str deleteCharactersInRange:NSMakeRange(5, 4)];
                [str insertString:@"****"atIndex:3];
                [_gtarrSiArr addObject:[NSString stringWithFormat:@"%@",str]];
            
            }
            
            for (NSMutableDictionary *dic in _ptarrSiArr)
            {
                NSMutableString *str= [[NSMutableString alloc]initWithString:[NSString stringWithFormat:@"%@",dic[@"pic1"]]];
                [str deleteCharactersInRange:NSMakeRange(0, 8)];
                [_poarrSiArr addObject:[NSString stringWithFormat:@"http://www.chaojihui123.com%@",str]];
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self.myTableView reloadData];
                });

            }
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.myTableView reloadData];
            });
        }
           } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"失败%@",error);
        }];
}

- (void)makeBaseUI{
    [self.view addSubview:self.myTableView];
    
}
#pragma mark - TableViewDelegate And DataSource

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 200;
    }else if(section == 3){
        return 150;
    }else if(section == 4){
        return 30;
    }else if(section>=3 &&section<=self.gongSiArr.count+4){
        return 1;
    }
    return  1;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        UIView *scrBackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 200)];
//        SMS_Scroll_ImageView *myView = [[SMS_Scroll_ImageView alloc]initWithSMS_ImagePath1:@"eat_" ImagePath2:@".png" ImageCount:3 IntervalTime:2 Frame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH , 200) PageControl:YES PageNumber:NO];
        SMS_Scroll_ImageView *myView = [[SMS_Scroll_ImageView alloc]initWithSMS_ImageURLArr:self.bannerArr IntervalTime:2 Frame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH , 200)  PageControl:YES Pagenumber:NO TitleFrame:CGRectZero];
        UIView *HendView= [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 200)];
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, ZTY_SCREEN_WIDTH, 100)];
        imageView.image = [UIImage imageNamed:@"1.png"];
        [HendView addSubview:imageView];
        [scrBackView addSubview:myView];
        [scrBackView addSubview:HendView];
        return scrBackView;
    }else if (section == 3){
        UIView * scrBackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 100)];
        UIView * hengView = [[UIView alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 15, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 1)];
        UIView * engView= [[UIView alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2+ZTY_SCREEN_WIDTH/6, 15, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 1)];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/12, 5, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 20)];
        scrBackView.backgroundColor = [UIColor whiteColor];
        label.text= @"猜你喜欢";
        engView.backgroundColor = [UIColor blackColor];
        hengView.backgroundColor = [UIColor blackColor];
        label.textColor = [UIColor getColorFromRGBString:@"#333333"];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont systemFontOfSize:15];
        [scrBackView addSubview:label];
        [scrBackView addSubview:hengView];
        [scrBackView addSubview:engView];
        
        
        self.imageNames = @[@"q1", @"q2", @"q3", @"q4", @"q5", @"q6", @"q7"];
        self.pagerView = [[FSPagerView alloc] initWithFrame:CGRectMake(0, 40, ZTY_SCREEN_WIDTH, 150)];
        self.pagerView.automaticSlidingInterval = 2.0;
        self.pagerView.dataSource = self;
        self.pagerView.itemSize = CGSizeMake(200, 150);
        self.pagerView.delegate = self;
        self.pagerView.transformer =  [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeLinear];
        [self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
        [scrBackView addSubview:self.pagerView];
        // Create a page control
        //FSPageControl *pageControl = [[FSPageControl alloc] initWithFrame:frame2];
        [scrBackView addSubview:self.pageControl];
        
        
        
        return scrBackView;
        
    }else if (section == 4){
        UIView * scrBackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 30)];
        UIView * hengView = [[UIView alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 15, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 1)];
        UIView * engView= [[UIView alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2+ZTY_SCREEN_WIDTH/6, 15, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 1)];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/12, 5, ZTY_SCREEN_WIDTH/2-ZTY_SCREEN_WIDTH/3, 20)];
        scrBackView.backgroundColor = [UIColor whiteColor];
        label.text= @"所有商家";
        engView.backgroundColor = [UIColor blackColor];
        hengView.backgroundColor = [UIColor blackColor];
        label.textColor = [UIColor getColorFromRGBString:@"#333333"];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont systemFontOfSize:15];
        [scrBackView addSubview:label];
        [scrBackView addSubview:hengView];
        [scrBackView addSubview:engView];
        
        return scrBackView;
        
    }
    return nil;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.gongSiArr.count+5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 240;
    }else if (indexPath.section  == 1){
        return 30;
    }else if (indexPath.section  == 2){
        return 200;
    }else if (indexPath.section >=4 && indexPath.section<=self.gongSiArr.count+3){
        return 80;
    }else if (indexPath.section==self.gongSiArr.count+4){
        return 30;
    }
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.textLabel.textAlignment = NSTextAlignmentLeft;
    }
    for(id temp in cell.contentView.subviews)
    {
        [temp removeFromSuperview];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.section == 0) {
        self.btn1 = [[UIButton alloc]init];
        [self.btn1 setImage:[UIImage imageNamed:@"5c0079eaac79c6981352793f6e89f964"] forState:UIControlStateNormal];
        self.btn1.backgroundColor = [UIColor whiteColor];
        self.btn1.backgroundColor = [UIColor whiteColor];
        [self.btn1 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn1 addTarget:self action:@selector(ShangPin:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn1];
        [self.btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell).offset(10);
            make.top.equalTo(cell).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab1 = [[UILabel alloc]init];
        self.lab1.font = [UIFont systemFontOfSize:16];
        self.lab1.textAlignment = NSTextAlignmentCenter;
        self.lab1.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab1.text =[NSString stringWithFormat:@"商品"];
        [cell.contentView addSubview:self.lab1];
        UITapGestureRecognizer *tapRecognizerWeibo1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ShangPin:)];
        self.lab1.userInteractionEnabled=YES;
        [self.lab1 addGestureRecognizer:tapRecognizerWeibo1];
        [self.lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell).offset(10);
            make.top.equalTo(self.btn1.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        self.btn2 = [[UIButton alloc]init];
        [self.btn2 setImage:[UIImage imageNamed:@"2"] forState:UIControlStateNormal];
        self.btn2.backgroundColor = [UIColor whiteColor];
        self.btn2.backgroundColor = [UIColor whiteColor];
        [self.btn2 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn2 addTarget:self action:@selector(FangWuBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn2];
        [self.btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn1.mas_right).offset(10);
            make.top.equalTo(cell).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab2 = [[UILabel alloc]init];
        self.lab2.font = [UIFont systemFontOfSize:16];
        self.lab2.textAlignment = NSTextAlignmentCenter;
        self.lab2.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab2.text =[NSString stringWithFormat:@"秀Time"];
        [cell.contentView addSubview:self.lab2];
        UITapGestureRecognizer *tapRecognizerWeibo2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(FangWuBtnAction:)];
        self.lab2.userInteractionEnabled=YES;
        [self.lab2 addGestureRecognizer:tapRecognizerWeibo2];
        [self.lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab1.mas_right).offset(10);
            make.top.equalTo(self.btn2.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        
        self.btn3 = [[UIButton alloc]init];
        [self.btn3 setImage:[UIImage imageNamed:@"3"] forState:UIControlStateNormal];
        self.btn3.backgroundColor = [UIColor whiteColor];
        self.btn3.backgroundColor = [UIColor whiteColor];
        [self.btn3 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn3 addTarget:self action:@selector(FangWuBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn3];
        [self.btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn2.mas_right).offset(10);
            make.top.equalTo(cell).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab3 = [[UILabel alloc]init];
        self.lab3.font = [UIFont systemFontOfSize:16];
        self.lab3.textAlignment = NSTextAlignmentCenter;
        self.lab3.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab3.text =[NSString stringWithFormat:@"贴吧"];
        [cell.contentView addSubview:self.lab3];
        UITapGestureRecognizer *tapRecognizerWeibo3=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(FangWuBtnAction:)];
        self.lab3.userInteractionEnabled=YES;
        [self.lab3 addGestureRecognizer:tapRecognizerWeibo3];
        [self.lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab2.mas_right).offset(10);
            make.top.equalTo(self.btn3.mas_bottom);
           make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));        }];
        
        self.btn4 = [[UIButton alloc]init];
        [self.btn4 setImage:[UIImage imageNamed:@"6"] forState:UIControlStateNormal];
        self.btn4.backgroundColor = [UIColor whiteColor];
        self.btn4.backgroundColor = [UIColor whiteColor];
        [self.btn4 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn4 addTarget:self action:@selector(FangWuBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn4];
        [self.btn4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn3.mas_right).offset(10);
            make.top.equalTo(cell).offset(10);
           make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab4 = [[UILabel alloc]init];
        self.lab4.font = [UIFont systemFontOfSize:16];
        self.lab4.textAlignment = NSTextAlignmentCenter;
        self.lab4.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab4.text =[NSString stringWithFormat:@"现金红包"];
        [cell.contentView addSubview:self.lab4];
        UITapGestureRecognizer *tapRecognizerWeibo4=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(FangWuBtnAction:)];
        self.lab4.userInteractionEnabled=YES;
        [self.lab4 addGestureRecognizer:tapRecognizerWeibo4];
        [self.lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab3.mas_right).offset(10);
            make.top.equalTo(self.btn4.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));        }];
        
        
        self.btn5 = [[UIButton alloc]init];
        [self.btn5 setImage:[UIImage imageNamed:@"4"] forState:UIControlStateNormal];
        self.btn5.backgroundColor = [UIColor whiteColor];
        self.btn5.backgroundColor = [UIColor whiteColor];
        [self.btn5 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn5 addTarget:self action:@selector(JiFenShangcheng:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn5];
        [self.btn5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell).offset(10);
            make.top.equalTo(self.lab1.mas_bottom).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab5 = [[UILabel alloc]init];
        self.lab5.font = [UIFont systemFontOfSize:16];
        self.lab5.textAlignment = NSTextAlignmentCenter;
        self.lab5.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab5.text =[NSString stringWithFormat:@"积分商城"];
        [cell.contentView addSubview:self.lab5];
        UITapGestureRecognizer *tapRecognizerWeibo5=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(JiFenShangcheng:)];
        self.lab5.userInteractionEnabled=YES;
        [self.lab5 addGestureRecognizer:tapRecognizerWeibo5];
        [self.lab5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell).offset(10);
            make.top.equalTo(self.btn5.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        self.btn6 = [[UIButton alloc]init];
        [self.btn6 setImage:[UIImage imageNamed:@"5"] forState:UIControlStateNormal];
        self.btn6.backgroundColor = [UIColor whiteColor];
        self.btn6.backgroundColor = [UIColor whiteColor];
        [self.btn6 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn6 addTarget:self action:@selector(YeShi:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn6];
        [self.btn6 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn5.mas_right).offset(10);
            make.top.equalTo(self.lab2.mas_bottom).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab6 = [[UILabel alloc]init];
        self.lab6.font = [UIFont systemFontOfSize:16];
        self.lab6.textAlignment = NSTextAlignmentCenter;
        self.lab6.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab6.text =[NSString stringWithFormat:@"夜市"];
        [cell.contentView addSubview:self.lab6];
        UITapGestureRecognizer *tapRecognizerWeibo6=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(YeShi:)];
        self.lab6.userInteractionEnabled=YES;
        [self.lab6 addGestureRecognizer:tapRecognizerWeibo6];
        [self.lab6 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab5.mas_right).offset(10);
            make.top.equalTo(self.btn6.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        
        self.btn7 = [[UIButton alloc]init];
        [self.btn7 setImage:[UIImage imageNamed:@"8"] forState:UIControlStateNormal];
        self.btn7.backgroundColor = [UIColor whiteColor];
        self.btn7.backgroundColor = [UIColor whiteColor];
        [self.btn7 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn7 addTarget:self action:@selector(DingZuo:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn7];
        [self.btn7 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn6.mas_right).offset(10);
            make.top.equalTo(self.lab3.mas_bottom).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab7 = [[UILabel alloc]init];
        self.lab7.font = [UIFont systemFontOfSize:16];
        self.lab7.textAlignment = NSTextAlignmentCenter;
        self.lab7.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab7.text =[NSString stringWithFormat:@"订座"];
        [cell.contentView addSubview:self.lab7];
        UITapGestureRecognizer *tapRecognizerWeibo7=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(DingZuo:)];
        self.lab7.userInteractionEnabled=YES;
        [self.lab7 addGestureRecognizer:tapRecognizerWeibo7];
        [self.lab7 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab6.mas_right).offset(10);
            make.top.equalTo(self.btn7.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        
        self.btn8 = [[UIButton alloc]init];
        [self.btn8 setImage:[UIImage imageNamed:@"7"] forState:UIControlStateNormal];
        self.btn8.backgroundColor = [UIColor whiteColor];
        self.btn8.backgroundColor = [UIColor whiteColor];
        [self.btn8 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn8 addTarget:self action:@selector(FangWuBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn8];
        [self.btn8 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn7.mas_right).offset(10);
            make.top.equalTo(self.lab4.mas_bottom).offset(10);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4,(ZTY_SCREEN_WIDTH-50)/4));
        }];
        self.lab8 = [[UILabel alloc]init];
        self.lab8.font = [UIFont systemFontOfSize:16];
        self.lab8.textAlignment = NSTextAlignmentCenter;
        self.lab8.textColor = [UIColor getColorFromRGBString:@"#707070"];
        self.lab8.text =[NSString stringWithFormat:@"积惠快报"];
        [cell.contentView addSubview:self.lab8];
        UITapGestureRecognizer *tapRecognizerWeibo8=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(FangWuBtnAction:)];
        self.lab8.userInteractionEnabled=YES;
        [self.lab8 addGestureRecognizer:tapRecognizerWeibo8];
        [self.lab8 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lab7.mas_right).offset(10);
            make.top.equalTo(self.btn8.mas_bottom);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-50)/4, 20));
        }];
        
    }else if(indexPath.section == 1){
        cell.backgroundColor=[UIColor getColorFromRGBString:@"#D63C50"];
        _weatherLab=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH*11, 30)];
//        for (int i = 0; i<_gtarrSiArr.count; i++) {
//            _weatherLab.text=[NSString stringWithFormat:@"%@",_gtarrSiArr[i]];
//        }
        NSString *colours = [_gtarrSiArr componentsJoinedByString:@"    ☆☆☆     "];
        _weatherLab.text = colours;
        _weatherLab.textColor=[UIColor whiteColor];
        _weatherLab.font=[UIFont systemFontOfSize:16];
        //    _weatherLab.backgroundColor=RGBCLEAR;
        [cell addSubview:_weatherLab];
        [self horseLight];
    }else if (indexPath.section == 2){
        self.btn9 = [[UIButton alloc]init];
        [self.btn9 setImage:[UIImage imageNamed:@"weishang"] forState:UIControlStateNormal];
        self.btn9.backgroundColor = [UIColor whiteColor];
        self.btn9.backgroundColor = [UIColor whiteColor];
        [self.btn9 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn9 addTarget:self action:@selector(ChengXinWeiShang:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn9];
        [self.btn9 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell).offset(5);
            make.top.equalTo(cell);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-20)/3,200));
        }];
        self.btn10 = [[UIButton alloc]init];
        [self.btn10 setImage:[UIImage imageNamed:@"zhigong"] forState:UIControlStateNormal];
        self.btn10.backgroundColor = [UIColor whiteColor];
        self.btn10.backgroundColor = [UIColor whiteColor];
        [self.btn10 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn10 addTarget:self action:@selector(ZhiGongJiHui:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn10];
        [self.btn10 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn9.mas_right).offset(5);
            make.top.equalTo(cell);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-20)/3,200));
        }];
        self.btn11 = [[UIButton alloc]init];
        [self.btn11 setImage:[UIImage imageNamed:@"shangchang"] forState:UIControlStateNormal];
        self.btn11.backgroundColor = [UIColor whiteColor];
        self.btn11.backgroundColor = [UIColor whiteColor];
        [self.btn11 setTitleColor:[UIColor getColorFromRGBString:@"#909090"] forState:UIControlStateNormal];
        [self.btn11 addTarget:self action:@selector(ShangCangSiHuo:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:self.btn11];
        [self.btn11 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btn10.mas_right).offset(5);
            make.top.equalTo(cell);
            make.size.mas_equalTo(CGSizeMake((ZTY_SCREEN_WIDTH-20)/3,200));
        }];
    }else if (indexPath.section >= 4 && indexPath.section<=self.gongSiArr.count+3){
         FirstOTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        if (!cell) {
            cell = [[FirstOTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell2"];
            cell.isFormFirst = YES;
        }
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        //cell.textLabel.text =[NSString stringWithFormat:@"222"];
        cell.textLabel.textColor = [UIColor orangeColor];
         cell.myModel = [self.gongSiArr cz_objectWithIndex:indexPath.section-4];
        return cell;
    }else if (indexPath.section == self.gongSiArr.count+4){
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell3"];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell3"];
            cell.textLabel.textAlignment = NSTextAlignmentLeft;
            
        }
        cell.textLabel.textAlignment = NSTextAlignmentCenter;
        cell.textLabel.text =[NSString stringWithFormat:@"更多商家>>"];
        cell.textLabel.textColor = [UIColor getColorFromRGBString:@"#060606"];
        return cell;
    }
    cell.textLabel.font = [UIFont systemFontOfSize:16];
    cell.detailTextLabel.text = @"1234";
    return cell;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [self.myTableView reloadData];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.section == self.gongSiArr.count+4) {
        SecondGViewController *vc=[[SecondGViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (indexPath.section >= 4 && indexPath.section<=self.gongSiArr.count+3){
        
        FirstTwoViewController *vc =[[FirstTwoViewController alloc]init];
        
        FirstModel *model=(FirstModel *)self.gongSiArr[indexPath.section-4];
        vc.dic = model.myid;
        [self.navigationController pushViewController:vc animated:YES];
        
    }
}

- (UITableView *)myTableView{
    
    if (_myTableView == nil) {
        _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, ZTY_SCREEN_HEIGHT-49) style:UITableViewStyleGrouped];
        _myTableView.dataSource = self;
        _myTableView.delegate = self;
        _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    
    return _myTableView;
    
}
-(void)horseLight
{
    //实现跑马灯效果
    CGRect frame = _weatherLab.frame;
    frame.origin.x = ZTY_SCREEN_WIDTH;
    _weatherLab.frame = frame;
    
    [UIView beginAnimations:@"testAnimation" context:NULL];
    [UIView setAnimationDuration:25.0f];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatAutoreverses:NO];
    [UIView setAnimationRepeatCount:999999];
    
    frame = _weatherLab.frame;
    frame.origin.x = -frame.size.width  + ZTY_SCREEN_WIDTH/30;
    _weatherLab.frame = frame;
    [UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)FangWuBtnAction:(UIButton *)sender{
    WebViewController *webVC = [[WebViewController alloc] init];
    [self.navigationController pushViewController:webVC animated:true];
}
- (void)JiFenShangcheng:(UIButton *)sender{
    JiFenViewController *sVc= [[JiFenViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];
    
}
-(void)YeShi:(UIButton *)sender
{
    YeShiViewController *sVc= [[YeShiViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];


}
-(void)DingZuo:(UIButton *)sender
{
    DingZuoViewController *sVc= [[DingZuoViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];

}
-(void)ShangPin:(UIButton *)sender
{
    ShangPinViewController*sVc= [[ShangPinViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];

}
-(void)ChengXinWeiShang:(UIButton *)sender
{
    ChengXinViewController *sVc= [[ChengXinViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];
    
}
-(void)ZhiGongJiHui:(UIButton *)sender
{
    ZhiGongJiHuiViewController *sVc= [[ZhiGongJiHuiViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];
    
}
-(void)ShangCangSiHuo:(UIButton *)sender
{
    ShangCangViewController *sVc= [[ShangCangViewController alloc]init];
    [self.navigationController pushViewController:sVc animated:YES];
    
}



- (NSInteger)numberOfItemsInPagerView:(FSPagerView *)pagerView
{
    return _poarrSiArr.count;
}

- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
    FSPagerViewCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
    
    
//    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",cachedImage]];
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:_poarrSiArr[index]] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
    cell.imageView.clipsToBounds = YES;
    
    return cell;
}

#pragma mark - FSPagerView Delegate

- (void)pagerView:(FSPagerView *)pagerView didSelectItemAtIndex:(NSInteger)index
{
    [pagerView deselectItemAtIndex:index animated:YES];
    [pagerView scrollToItemAtIndex:index animated:YES];
    self.pageControl.currentPage = index;
}

- (void)pagerViewDidScroll:(FSPagerView *)pagerView
{
    if (self.pageControl.currentPage != pagerView.currentIndex) {
        self.pageControl.currentPage = pagerView.currentIndex;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
